package com.sicurezza.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import com.progettoSicurezza.db.KeyContactContract.KeyContactEntry;

public class KeyContactDbHelper extends SQLiteOpenHelper{
	
	public static final int DATABASE_VERSION = 1;
	public static final String DATABASE_NAME = "KeyContact.db";
	private static final String TEXT_TYPE = " TEXT";
	private static final String COMMA_SEP = ",";
	private static final String SQL_CREATE_ENTRIES = "CREATE TABLE " + KeyContactEntry.TABLE_NAME + " (" + KeyContactEntry._ID + 
													" INTEGER PRIMARY KEY" + KeyContactEntry.CONTACT_ID + TEXT_TYPE + COMMA_SEP + KeyContactEntry.CONTACT_DISPLAY_NAME +
													TEXT_TYPE + COMMA_SEP + KeyContactEntry.CONTACT_PHONE_NUMBER + TEXT_TYPE + COMMA_SEP + KeyContactEntry.CONTACT_EMAIL_ADDRESS +
													TEXT_TYPE + COMMA_SEP + KeyContactEntry.SALT_STRING_VALUE + TEXT_TYPE + COMMA_SEP + KeyContactEntry.KEY_HASH_VALUE + TEXT_TYPE + " )";
	private static final String SQL_DELETE_ENTRIES = "DROP TABLE IF EXISTS " + KeyContactEntry.TABLE_NAME;

	public KeyContactDbHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(SQL_CREATE_ENTRIES);
		
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		/*ne parliamo alla versione 2 se ci sara, 
		 * aggiunta immagine contatto per la versione 2
		 */
	}
}
